class Solution {
public:
    int titleToNumber(string s) {
        int res = 0;
        for(char c : s)
        {
            res *= 26;
            res += convert(c);
        }
        return res;
    }
    int convert(char c) {
        return c - 'A' + 1;
    }
};
